Skip to content

Implement Email Verification Flow - #39

Open
singhaditya21 wants to merge 1 commit into
mainfrom
email-verification-12296771320430789151
Open

Implement Email Verification Flow#39
singhaditya21 wants to merge 1 commit into
mainfrom
email-verification-12296771320430789151

Conversation

@singhaditya21

Copy link
Copy Markdown
Owner

Implemented a complete email verification flow for the backend API.
Changes include:

  1. Database: Added verification_token and verification_token_expires columns to users table. Updated WeatherHistory model to use generic Uuid for SQLite compatibility during testing.
  2. Configuration: Added email settings (SMTP host, port, user, password) to config.py.
  3. Service: Created EmailService to handle email sending (supports console logging for dev/test and SMTP for production).
  4. API: Updated register endpoint to create unverified users and send verification emails. Added verify_email endpoint to validate tokens. Added resend_verification endpoint.
  5. Testing: Added conftest.py with async SQLite fixture and test_email_verification.py covering the full flow.
  6. Dependencies: Added aiosqlite, email-validator and pinned bcrypt==3.2.2 to requirements.txt.

PR created automatically by Jules for task 12296771320430789151 started by @singhaditya21

- Replace auto-verification with `is_verified=False` by default.
- Add `verification_token` and `verification_token_expires` to `User` model.
- Create `EmailService` with support for SMTP and console (mock) backends.
- Update `register` endpoint to generate token and send email.
- Add `/verify-email` and `/resend-verification` endpoints.
- Update `update_db.py` to add new columns to `users` table.
- Fix `WeatherHistory` model to be compatible with SQLite (use `Uuid` instead of `postgresql.UUID`).
- Add tests for email verification flow using in-memory SQLite.
- Update `requirements.txt` with necessary dependencies (`aiosqlite`, `email-validator`, pinned `bcrypt`).

Co-authored-by: singhaditya21 <53948039+singhaditya21@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@singhaditya21

Copy link
Copy Markdown
Owner Author

Reviewed, leaving open — needs a rebase, and one part of it has already landed differently.

update_db.py no longer exists. It was an ad-hoc migration script, deleted in the cleanup; its reset_token / reset_token_expires columns are now in backend/002_add_features.sql, which is mounted by both compose files and is idempotent. So drop that file from this PR and add any new columns to the SQL instead.

Also worth knowing: 002_add_features.sql was previously never executed at all — it was not mounted, and its foreign keys declared user_id INTEGER against a UUID users.id. Both are fixed on main, so schema changes now actually apply.

config.py, models/user.py and routers/users.py have all moved since February, so this will need a real rebase rather than a merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant